#ifndef HANDTRACKER_H
#define HANDTRACKER_H

#include <cv.h>
#include "handgestureexception.h"
#include "handlostexception.h"

namespace mlgesture {

class HandTracker
{
public:
	HandTracker();
	HandTracker(const cv::Mat& frame, const cv::Rect& hand, const cv::Mat mask = cv::Mat(),
				const double tracking_sensity = 0.9);
	~HandTracker();
	void init(const cv::Mat& frame, const cv::Rect& hand, const cv::Mat mask = cv::Mat(),
			  const double trackin_sensity = 0.9) throw(HandGestureException);
	cv::Rect track(const cv::Mat& frame, const cv::Mat& skin_mask) throw(HandGestureException, HandLostException);
	cv::Rect getHandRect() const throw(HandGestureException);
	void setTrackingSensity(double sensity);

private:
	cv::Mat trackHist_;
	cv::Mat trackBackProject_;
	cv::Rect handRect_;
	cv::KalmanFilter kFilter_;
	int trackHistSize_;
	float trackHistRanges_[2];
	int trackHistChannel_;
	const float* trackHistPRanges_;
	cv::Point handLastPos_;
	cv::Mat kalmanMeasurement_;
	cv::Mat prevValue_;
	double trackingSensity_;
	int lostCount_;
};

}

#endif // HANDTRACKER_H
